<--- %%NOBANNER%% --> xread.sas
 BackForward
/* %put %xread(this is a test(distinct rassignn, visit, count(distinct pt) as totpt)); */
%macro xread(_string_);
%if (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(&_string_))))), %str(%()) eq 1) and
    (%index(%BQUOTE(%trim(%BQUOTE(%left(%BQUOTE(%sysfunc(reverse(&_string_))))))), %str(%))) eq 1) %then
   %let _string_=%substr(%quote(%trim(%quote(%left(%quote(&_string_))))), 2, %eval(%length(%trim(%quote(%left(%quote(&_string_)))))-2));
%let _xrx_=%sysfunc(rxparse($(1))); %let _xpos_=0; %let _xlen_=0; %let _xoldstr_=; %let _xnewstr_=;
%do %while( %sysfunc(rxmatch(&_xrx_, %quote(&_string_))) );
   %syscall rxsubstr(_xrx_, _string_, _xpos_, _xlen_);
   %let _xoldstr_=%quote(%substr(%quote(&_string_), &_xpos_, &_xlen_));
   %let _xnewstr_=%quote(%sysfunc(translate(%quote(&_xoldstr_), À, %quote(%(), Á, %quote(%)), ´, %quote(,), ®, %quote( ))));
   %let _string_=%sysfunc(tranwrd(%quote(&_string_), %quote(&_xoldstr_), %quote(&_xnewstr_)));
   %let _xpos_=0; %let _xlen_=0; %let _xoldstr_=; %let _xnewstr_=;
%end; &_string_;
%mend xread;